package com.ykq.system.controller;

import com.ykq.system.service.IPermissionService;
import com.ykq.system.vo.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 权限 前端控制器
 * </p>
 *
 * @author 闫克起
 * @since 2022-08-08
 */
@RestController
@RequestMapping("/system/permission")
public class PermissionController {

    @Autowired
    private IPermissionService permissionService;

    @GetMapping("leftMenu")
    public CommonResult leftMenu(HttpServletRequest request){
        String token = request.getHeader("token");
        return permissionService.findPermissionByUserId(token);
    }

    @GetMapping("findPermessionByRoleId/{roleId}")
    public CommonResult findPermessionByRoleId(@PathVariable String roleId){
        return permissionService.findPermessionByRoleId(roleId);
    }
}
